/**
 * @param {number[]} nums
 * @return {number}
 */
function missingNumber (nums) {
  let result = nums.length
  nums.sort(function (value1, value2) {
    if (value1 < value2) {
      return -1
    } else if (value1 > value2) {
      return 1
    } else {
      return 0
    }
  })
  let len = nums.length > 3 ? nums.length : 3
  for (let i = 0; i < len; i++) {
    if (nums[i] != i) {
      result = i
      break
    }
  }
  return result
}

let nums = [3, 0, 1]
nums = [1]
// nums = [9, 6, 4, 2, 3, 5, 7, 0, 1]
console.log('结果', missingNumber(nums))